<template>
	<view class="">
		<cu-custom isLeft isBack>
			<view slot="content" class="head">
				推荐
			</view>
		</cu-custom>
		<view class="head_bg">
			<image src="@/packagesC/static/tuijian_bg.png" mode=""></image>
		</view>
		<view class="box">
			<view @click="toPage(`/pagesPet/pages/leaflet/detail?id=${item.id}`)" v-for="(item,index) in list" :key="index" class="item">
				<view class="item_top">
					<image :src="item.picture" mode=""></image>
				</view>
				<view class="item_bottom">
					<view class="item_bottom_title">
						{{item.title}}
					</view>
				</view>
			</view>
			<data-null :top="250" v-if="!list.length"></data-null>
		</view>
		<!-- <view class="car">
			<image src="@/packagesC/static/car.png" mode=""></image>
			<view class="car_num">
				3
			</view>
		</view> -->
	</view>
</template>

<script>
	import {pageLeaflet} from "@/api/pet/leaflet/index.js"
	export default {
		data(){
			return{ 
				params:{
					page:1,
					limit:10
				},
				list:[],
				total:0,
			}
		},
		onLoad(){
			this.reg()
		},
		onPullDownRefresh() {
			this.reg()
		},
		onReachBottom() {
			if (this.total > this.list.length) {
				this.params.page++;
				this.getList()
			}
		},
		methods:{
			getList(){
				uni.showLoading({
					title:'加载中',
					mask:true
				})
				pageLeaflet(this.params).then(res=>{
					this.list = [...this.list,...res.rows]
					this.total = res.total
					uni.hideLoading()
					uni.stopPullDownRefresh()
				})
			},
			toPage(url){
				uni.navigateTo({
					url:url
				})
			},
			reg(){
				this.params.page = 1
				this.list = []
				this.getList()
			}
		}
	}
</script>
<style>
	page{
		background: #f8f8f8;
	}
</style>
<style lang="scss" scoped>
	.head{
		
	}
	.head_bg{
		width: 100%;
		height: 611rpx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: -1;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.box{
		width: 100%;
		padding: 27rpx 24rpx;
		box-sizing: border-box;
		.item{
			width: 100%;
			background: #FFFFFF;
			border-radius: 14rpx;
			overflow: hidden;
			.item_top{
				width: 100%;
				height: 380rpx;
				position: relative;
				image{
					width: 100%;
					height: 100%;
				}
				.item_top_num{
					padding: 0 12rpx;
					background: rgba(0,0,0,0.6);
					border-radius: 8rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 22rpx;
					color: var(--h4Color);
					line-height: 38rpx;
					position: absolute;
					right: 36rpx;
					bottom: 28rpx;
				}
			}
			.item_bottom{
				width: 100%;
				padding: 24rpx;
				box-sizing: border-box;
				.item_bottom_title{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: var(--h1Color);
					line-height: 42rpx;
				}
				.item_bottom_content{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.item_content_left{
						display: flex;
						align-items: flex-end;
						.item_now{
							font-family: DINPro, DINPro;
							font-weight: 500;
							font-size: 26rpx;
							color: var(--primaryBg);
							line-height: 33rpx;
							display: inline-block;
							margin-right: 16rpx;
							view{
								font-size: 36rpx;
								line-height: 36rpx;
								display: inline-block;
							}
						}
						.item_old{
							font-family: DINPro, DINPro;
							font-weight: 400;
							font-size: 26rpx;
							color: var(--h3Color);
							line-height: 33rpx;
							text-decoration-line: line-through;
						}
					}
					.item_content_right{
						display: flex;
						justify-content: center;
						view{
							width: 136rpx;
							font-family: PingFangSC, PingFang SC;
							font-weight: 600;
							font-size: 28rpx;
							line-height: 72rpx;
							text-align: center;
							&:first-child{
								color: var(--primaryBg);
								background: #FFF0EF;
								border-radius: 35rpx 0 0 35rpx;
							}
							&:last-child{
								color: #fff;
								background: var(--primaryBg);
								border-radius: 0rpx 35rpx 35rpx 0rpx;
							}
						}
					}
				}
			}
		}
	}
	.car{
		position: fixed;
		right: 20rpx;
		bottom: 92rpx;
		width: 116rpx;
		height: 116rpx;
		image{
			width: 100%;
			height: 100%;
		}
		.car_num{
			position: absolute;
			top: 5rpx;
			right: 5rpx;
			background: var(--primaryBg);
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 20rpx;
			color: #FFFFFF;
			line-height: 30rpx;
			padding: 0 8rpx;
			border-radius: 30rpx;
		}
	}
</style>